<?php
/**
 * @package		Joomla.Site
 * @subpackage	Templates.beez5
 * @copyright	Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 **/
// No direct access
defined('_JEXEC') or die;

$app = JFactory::getApplication();
$templateparams = $app->getTemplate(true)->params;
$images = json_decode($this->item->images);
$urls = json_decode($this->item->urls);
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');
$lang =& JFactory::getLanguage();
$langdefault = $lang->getTag();

// Create shortcut to parameters.
$params = $this->item->params;

//check if products menu
$idcat = JRequest::getVar('catid','','get','int');
$db = JFactory::getDbo();
$sql = "SELECT * from #__categories where id = '".$idcat."' and parent_id = 78 and published=1";
$db->setQuery($sql);
$db->query($sql);
$result = $db->getNumRows();
if($result==1) $class = 'cat_mod'; else $class = '';
?>

<div class="swap_products_detail <?php echo $class;?>">
    <div class="content_full <?php echo $class;?>">
        <div class="title"><?php echo $this->escape($this->item->title); ?></div>
        <div class="detai_page <?php echo $class;?>">            
            <?php echo $this->item->event->beforeDisplayContent; ?>
            <?php echo $this->item->text; ?>
            <?php echo $this->item->event->afterDisplayContent; ?>
        </div>        
        <?php 
        $db = JFactory::getDbo();
        $query = "SELECT c.*, ca.parent_id as parent_cat from #__content as c LEFT JOIN #__categories as ca ON c.catid=ca.id where c.catid='".$this->item->catid."' and c.id != '".$this->item->id."' and c.language = '".$langdefault."' order by c.id DESC";
        $db->setQuery($query);
        $db->query();        
        $result = $db->loadObjectList();        
        ?>
        <span id="ctl00_ContentPlaceHolder1_sTinKhac" style="color:red; font-weight:bold; padding: 10px 0px; display: block; clear: both;">
        <?php if($result){?>
        <?php if($result[0]->parent_cat==78) echo JText::_('OTHERPRODUCTS'); else echo JText::_('OTHERNEWS');?>
        <?php }?>
        </span>
        <?php foreach($result as $obj){?>
        <div class="new_more_loaitin">
                <a class="link" href="<?php echo JRoute::_(ContentHelperRoute::getArticleRoute($obj->id, $obj->catid));?>"> 
                <span id="ctl00_ContentPlaceHolder1_rptTinLienQuan_ctl00_Literal1" title="<?php echo $obj->title;?>"><?php echo $obj->title;?></span></a>
                <span style="color:#a1a0a0; padding-left: 5px;">(<?php echo date('Y/m/d',strtotime($obj->created));?>)</span>
            </div>
            <?php }?>
    </div>
</div>


